package com.group.EducationalSystem.tools;

import java.util.Calendar;
import java.util.Date;

import com.alibaba.druid.sql.ast.statement.SQLIfStatement.Else;

public class Time {
	public String AdmissionTime(String account){
		String admissionTime = "";
		for(int i=0;i<4;i++){
			admissionTime = admissionTime + account.charAt(i);
		}
		admissionTime = admissionTime+"年9月1日";
		return admissionTime;
	}
	
	public String ClosingTime(String account){
		String closeTime = "";
		for(int i=0;i<4;i++){
			closeTime = closeTime + account.charAt(i);
		}
		int closetime = Integer.parseInt(closeTime);
		closetime+=4;
		closeTime = closetime+"年7月15日";
		return closeTime;
	}
	
	public String Grade(String account){
		String admissionTime = "";
		for(int i=0;i<4;i++){
			admissionTime = admissionTime + account.charAt(i);
		}
		int admissiontime = Integer.parseInt(admissionTime);
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(new Date());
		calendar.get(Calendar.YEAR);
		if(admissiontime+4<calendar.get(Calendar.YEAR)){
			return "您已结业";
		}else if(admissiontime+4==calendar.get(Calendar.YEAR)&&calendar.get(Calendar.MONTH)>7){
			return "您已结业";
		}
		else{
			if(calendar.get(Calendar.YEAR)-admissiontime==0&&calendar.get(Calendar.MONTH)>=9&&calendar.get(Calendar.MONTH)<=12){
				return "大一上学期";
			}else if(calendar.get(Calendar.YEAR)-admissiontime==1&&calendar.get(Calendar.MONTH)>=1&&calendar.get(Calendar.MONTH)<=7){
				return "大一下学期";
			}else if(calendar.get(Calendar.YEAR)-admissiontime==1&&calendar.get(Calendar.MONTH)>=9&&calendar.get(Calendar.MONTH)<=12){
				return "大二上学期";
			}else if(calendar.get(Calendar.YEAR)-admissiontime==2&&calendar.get(Calendar.MONTH)>=1&&calendar.get(Calendar.MONTH)<=7){
				return "大二下学期";
			}else if(calendar.get(Calendar.YEAR)-admissiontime==2&&calendar.get(Calendar.MONTH)>=9&&calendar.get(Calendar.MONTH)<=12){
				return "大三上学期";
			}else if(calendar.get(Calendar.YEAR)-admissiontime==3&&calendar.get(Calendar.MONTH)>=1&&calendar.get(Calendar.MONTH)<=7){
				return "大三下学期";
			}else if(calendar.get(Calendar.YEAR)-admissiontime==3&&calendar.get(Calendar.MONTH)>=9&&calendar.get(Calendar.MONTH)<=12){
				return "大四上学期";
			}else if(calendar.get(Calendar.YEAR)-admissiontime==3&&calendar.get(Calendar.MONTH)>=1&&calendar.get(Calendar.MONTH)<=7){
				return "大四下学期";
			}
		}
		return "数据错误";
	}
	
	public String GradeStatue(String account) {
		String statue = Grade(account);
		if(statue.equals("你已结业")) {
			return statue;
		}else if(statue.equals("数据错误")){
			return statue;
		}else {
			return "目前为"+statue;
		}
		
	}

	
	
}
